<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"/>
    <title>HELLO，AMAP!</title>
    <style>
        html,
        body,
        #container {
          width: 100%;
          height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script type="text/javascript">
    window._AMapSecurityConfig = {
      securityJsCode: "b0efc70828069f1a870552e755415dcd",
    };
</script>
<script
        type="text/javascript"
        src="https://webapi.amap.com/maps?v=2.0&key=d3f7ea35a123d32cf985f1e451264f52"
></script>
<script type="text/javascript">
    var zoom = 16
    //地图初始化应该在地图容器 <div> 已经添加到 DOM 树之后
    var map = new AMap.Map("container", {
      zoom: zoom, //地图的缩放级别
      center:[118.779105,31.991412] //地图的中心点坐标
    });

    //设置驾车的路线规划
    function setDrivingLine(start,end){
        var driving;
        const points = [
          { keyword: start}, //起始点坐标
          { keyword: end} //终点坐标
        ]

        map.plugin(["AMap.Driving"], function() { //加载驾车服务插件
           var drivingOptions = {
               //驾车策略，包括 LEAST_TIME，LEAST_FEE, LEAST_DISTANCE,REAL_TRAFFIC
               policy: AMap.DrivingPolicy.LEAST_TIME,
               map:map
           };
           driving = new AMap.Driving(drivingOptions);

           //获取起终点规划线路
          driving.search(points, function (status, result) {});
        });
    }

<!--    window.onload=function(){-->
<!--        setDrivingLine("上海火车站","武昌站")-->
<!--    }-->
</script>